﻿using Minecraft.Config;
using Minecraft.Model;
using Minecraft.Model.ReqResp;
using SuperSocket.SocketBase.Command;
using SuperSocket.SocketBase.Protocol;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Minecraft.ServerHall.Cmd
{
	public class FurnitureOutputTypeListSelectTemp : CommandBase<MinecraftSession, StringRequestInfo>
	{
		public override string Name
		{
			get
			{
				return ProtocolHelper.GetProtocolStr(defCommand);
			}
		}
		private EnumCommand defCommand = EnumCommand.Furniture_FurnitureOutputTypeListSelectTemp;
		public override void ExecuteCommand(MinecraftSession session, StringRequestInfo requestInfo)
		{
			var req = requestInfo.GetRequestObj<FurnitureOutputTypeListSelectTempReq>(session);
			if (req == null)
			{
				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误1：（原因：请求实体为空）" });
				return;
			}
			if (!session.minecraftSessionInfo.IsLogin)
			{
				session.Send(defCommand, req, new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误1：（原因：未登录）" });
				return;
			}
			var furnitureOutputBriefList = (from item in session.minecraftSessionInfo.furnitureOutputList
											select new FurnitureOutputBrief
											{
												furnitureId = item.FurnitureId,
												point3 = new Point3
												{
													x = item.Point_X,
													y = item.Point_Y,
													z = item.Point_Z
												},
											}).ToList();

			var resp = new FurnitureOutputTypeListSelectTempResp
			{
				furnitureOutputBriefList = furnitureOutputBriefList
			};
			session.Send(defCommand,req, resp);
		}
	}
}
